<!-- include "menu" -->
<div id='main-site-globalbo-moduleSpace-cms-content'>
	<!-- loop contents -->
	<div class='main-site-globalbo-moduleSpace-cms-content-edit'>
		<div class='main-site-globalbo-moduleSpace-cms-content-edit-title'>{{contents' value.@cnt_real_name}}</div>
		<textarea rows="10" cols="70" class='textarea-content' name="text_area_{{contents' value.@cnt_id}}">{{contents' value.@cnt_content}}</textarea>
		<input type='hidden' name='id_content' value="{{contents' value.@cnt_id}}" class='id_content_value'>
		<div class='main-site-globalbo-moduleSpace-cms-content-edit-ajax_response'></div>
		<input type='button' value='Enregistrer' class='personal-button fright'>
	</div>
	<!-- endloop -->
</div>

<script type="text/javascript">
$('.main-site-globalbo-moduleSpace-cms-content-edit-ajax_response').hide();
$(document).ready(function(){	
	$(".personal-button").click(function(){
		if(confirm('Êtes-vous sûr de vouloir enregistrer la modfication ?')){
			var id = $(this).siblings(".id_content_value").val();
			var content = tinyMCE.get('text_area_'+id).getContent();
			var data = "id_content="+id+"&content="+content;
			var response_zone = $(this).siblings(".main-site-globalbo-moduleSpace-cms-content-edit-ajax_response"); 
			var url="{{baseurl}}admin/frbCms/frbCms_MainController/index";
			$.ajax({
				urlApp: url,
				type: 'POST',
				cache: false,
				data: data,
				success: function(html){
					if(html=="true"){
						response_zone.attr('class', 'main-site-globalbo-moduleSpace-cms-content-edit-ajax_response gresponse');
						response_zone.html('Modification enregistrée');
						response_zone.fadeIn('slow');
					}else{
						response_zone.attr('class', 'main-site-globalbo-moduleSpace-cms-content-edit-ajax_response bresponse');
						response_zone.html("Erreur lors de l'enregistrement. Aucune modification effectuée");
						response_zone.fadeIn('slow');
					}
				}
			});	
		}
	});
});
</script>

<script type="text/javascript" src="{{baseurl}}global/js/globalbo/tiny_mce/tiny_mce.js" ></script >
<script type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        language : "en",
        entity_encoding : 'false',
        theme : "simple"   //(n.b. no trailing comma, this will be critical as you experiment later)
});
</script>
